﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Dev.DevNet.IServices
{
    public  interface IDbBaseService<T> where T :class,new ()
    {
        /// <summary>
        /// 新增数据
        /// </summary>
        /// <param name="t">实体</param>
        /// <returns>新增条数</returns>
        public int Add(T t);
        /// <summary>
        /// 新增返回自增ID
        /// </summary>
        /// <returns>返回自增ID</returns>
        public int AddReturnIdentity(T t);

        /// <summary>
        /// 删除实体
        /// </summary>
        /// <param name="t">实体</param>
        /// <returns>受影响行数</returns>
        public int Delete(T t);
        /// <summary>
        /// 筛选条件删除
        /// </summary>
        /// <param name="expression">表达式</param>
        /// <returns>受影响行数</returns>
        public int Delete(Expression<Func<T, bool>> expression);
       
        /// <summary>
        /// 单条更新
        /// </summary>
        /// <param name="t">更新实体</param>
        /// <returns>受影响行数</returns>
        public int Update(T t);
        /// <summary>
        /// 批量更新
        /// </summary>
        /// <param name="UpdateObjs">更新集合数据</param>
        /// <returns>受影响行数</returns>
        public int Update(List<T> UpdateObjs);
        /// <summary>
        /// 根据表达式查询
        /// </summary>
        /// <param name="expression">表达式</param>
        /// <returns>ISugarQueryable<T> </returns>
        ISugarQueryable<T> QueryWhere(Expression<Func<T, bool>> expression);



    }
}
